home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH3 / SRC / PALEDIT.BAS < prev    next >
BASIC Source File  |  1997-01-03  |  4KB  |  70 lines

  1. Attribute VB_Name = "PalEdit"
  2. Option Explicit
  3.  
  4. Type PALETTEENTRY
  5.     peRed As Byte
  6.     peGreen As Byte
  7.     peBlue As Byte
  8.     peFlags As Byte
  9. End Type
  10. Public Const PC_EXPLICIT = &H2      ' Match to system palette index.
  11. Public Const PC_NOCOLLAPSE = &H4    ' Do not match color existing entries.
  12.  
  13. ' GetDeviceCaps constants.
  14. Global Const RASTERCAPS = 38    ' Raster device capabilities.
  15. Global Const RC_PALETTE = &H100 ' Has palettes.
  16. Global Const NUMRESERVED = 106  ' # reserved entries in palette.
  17. Global Const SIZEPALETTE = 104  ' Size of system palette.
  18.  
  19. #If Win32 Then  ' 32-bit VB.
  20.     Type BITMAP ' 24 bytes
  21.         bmType As Long
  22.         bmWidth As Long
  23.         bmHeight As Long
  24.         bmWidthBytes As Long
  25.         bmPlanes As Integer
  26.         bmBitsPixel As Integer
  27.         bmBits As Long
  28.     End Type
  29.     Global Const BITMAP_SIZE = 24
  30.     Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
  31.     Declare Function ResizePalette Lib "gdi32" (ByVal hPalette As Long, ByVal nNumEntries As Long) As Long
  32.     Declare Function SetPaletteEntries Lib "gdi32" (ByVal hPalette As Long, ByVal wStartIndex As Long, ByVal wNumEntries As Long, lpPaletteEntries As PALETTEENTRY) As Long
  33.     Declare Function GetPaletteEntries Lib "gdi32" (ByVal hPalette As Long, ByVal wStartIndex As Long, ByVal wNumEntries As Long, lpPaletteEntries As PALETTEENTRY) As Long
  34.     Declare Function GetSystemPaletteEntries Lib "gdi32" (ByVal hdc As Long, ByVal wStartIndex As Long, ByVal wNumEntries As Long, lpPaletteEntries As PALETTEENTRY) As Long
  35.     Declare Function RealizePalette Lib "gdi32" (ByVal hdc As Long) As Long
  36.     Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
  37.     Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
  38.  
  39. Type RECT
  40.     Left As Long
  41.     Top As Long
  42.     Right As Long
  43.     Bottom As Long
  44. End Type
  45. Declare Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
  46. Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
  47. Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  48.  
  49. #Else           ' 16-bit VB.
  50.     Type BITMAP ' 14 bytes
  51.         bmType As Integer
  52.         bmWidth As Integer
  53.         bmHeight As Integer
  54.         bmWidthBytes As Integer
  55.         bmPlanes As String * 1
  56.         bmBitsPixel As String * 1
  57.         bmBits As Long
  58.     End Type
  59.     Global Const BITMAP_SIZE = 14
  60.     Declare Function GetDeviceCaps Lib "GDI" (ByVal hdc As Integer, ByVal nIndex As Integer) As Integer
  61.     Declare Function ResizePalette Lib "GDI" (ByVal hPalette As Integer, ByVal nNumEntries As Integer) As Integer
  62.     Declare Function SetPaletteEntries Lib "GDI" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  63.     Declare Function GetPaletteEntries Lib "GDI" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  64.     Declare Function GetSystemPaletteEntries Lib "GDI" (ByVal hdc As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  65.     Declare Function RealizePalette Lib "User" (ByVal hdc As Integer) As Integer
  66.     Declare Function GetBitmapBits Lib "GDI" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  67.     Declare Function GetObject Lib "GDI" (ByVal hObject As Integer, ByVal nCount As Integer, lpObject As Any) As Integer
  68. #End If
  69.  
  70.